home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Blitter / DrawLine.s < prev    next >
Encoding:
Text File  |  1997-05-03  |  2.0 KB  |  98 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Draw Line
  3. ;---------
  4. ;This demo draws a line which you can control with the mouse.
  5.  
  6.     INCDIR    "INCLUDES:"
  7.     INCLUDE    "games/games_lib.i"
  8.     INCLUDE    "games/games.i"
  9.  
  10. CALL    MACRO
  11.     jsr    _LVO\1(a6)
  12.     ENDM
  13.  
  14. ;===========================================================================;
  15. ;                             INITIALISE DEMO
  16. ;===========================================================================;
  17.  
  18.     SECTION    "DrawLine",CODE
  19.  
  20.     STARTGMS
  21.  
  22. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  23.     move.l    GMSBase(pc),a6
  24.     CALL    AllocBlitter
  25.     tst.l    d0
  26.     bne.s    .Error_Blitter
  27.  
  28.     lea    ScreenTags(pc),a0
  29.     CALL    ShowScreen
  30.     tst.l    d0
  31.     beq.s    .Error_Screen
  32.  
  33.     bsr.s    Loop
  34.  
  35. .ReturnToDOS
  36.     move.l    GMSBase(pc),a6
  37.     move.l    Screen(pc),a0
  38.     CALL    DeleteScreen
  39. .Error_Screen
  40.     CALL    FreeBlitter
  41. .Error_Blitter
  42.     MOVEM.L    (SP)+,A0-A6/D1-D7
  43.     moveq    #ERR_OK,d0
  44.     rts
  45.  
  46. ;===========================================================================;
  47. ;                                MAIN LOOP
  48. ;===========================================================================;
  49.  
  50. Loop:    move.l    Screen(pc),a0
  51.     moveq    #BUFFER2,d0
  52.     CALL    ClrScreen
  53.  
  54.     moveq    #JPORT1,d0
  55.     CALL    ReadMouse
  56.     btst    #MB_RMB,d0
  57.     bne.s    .done
  58.     lea    MouseDXY(pc),a1
  59.     btst    #MB_LMB,d0
  60.     beq.s    .no
  61.     lea    MouseSXY(pc),a1
  62. .no    move.w    d0,d1
  63.     ext.w    d1
  64.     add.w    d1,2(a1)
  65.     asr.w    #8,d0
  66.     add.w    d0,(a1)
  67.  
  68. .Draw    moveq    #BUFFER2,d0    ;d0 = Buffer
  69.     movem.w    MouseSXY(pc),d1/d2/d3/d4    ;d1 = XStart, YStart, XEnd, YEnd.
  70.     moveq    #2,d5    ;d5 = Colour
  71.     CALL    DrawLine
  72.     CALL    WaitVBL
  73.     CALL    SwapBuffers
  74.     bra.s    Loop
  75. .done    rts
  76.  
  77. MouseSXY
  78.     dc.w    160,128
  79. MouseDXY
  80.     dc.w    40,40
  81.  
  82. ;===========================================================================;
  83. ;                                  DATA
  84. ;===========================================================================;
  85.  
  86. ScreenTags:
  87.     dc.l    TAGS_GAMESCREEN
  88. Screen:    dc.l    0
  89.     dc.l    GSA_Palette,.Palette
  90.     dc.l    GSA_AmtColours,4
  91.     dc.l    GSA_ScrWidth,640
  92.     dc.l    GSA_ScrHeight,256
  93.     dc.l    GSA_Attrib,DBLBUFFER
  94.     dc.l    GSA_ScrMode,HIRES
  95.     dc.l    TAGEND
  96. .palette
  97.     dc.l    $000000,$f0f0f0,$f000f0,$f00000
  98.